/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 62536
 * Date: 2024-06-28
 * Time: 16:36
 */
public class Solution {
    public static void main(String[] args) {
        int[] nums = {0,10,10,10,10,10,10,10,10,10,-10,10,10,10,10,10,10,10,10,10,0};
        System.out.println(maxProduct(nums));
    }
    public static int maxProduct(int[] nums) {
        int n = nums.length;
        int[] f = new int[n+1];
        int[] g = new int[n+1];
        int ret = Integer.MIN_VALUE;
        f[0] = g[0] = 1;
        for (int i = 1; i <= n; i++) {
            int x = nums[i-1];
            int y = f[i-1] * nums[i-1];
            int z = g[i-1] * nums[i-1];

            f[i] = Math.max(x,Math.max(y,z));
            g[i] = Math.min(x,Math.min(y,z));
            ret = Math.max(ret, f[i]);
        }

        return ret;


    }
    
}
